package com.gusti.admincasa.model;

import java.util.GregorianCalendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

import com.gusti.admincasa.persistence.model.AbstractModelObject;

/**
 * 
 * @author gusti
 *
 */
@Entity
public class Message extends AbstractModelObject {

	@ManyToOne
	@JoinColumn(name = "ownerId", nullable = false)
	private User owner;
	@ManyToOne
	@JoinColumn(name = "senderId", nullable = true)
	private User sender;
	@Column( length=1000  )
	private String message;
	private boolean readed;
	private GregorianCalendar sendDate;

	public User getOwner() {
		return owner;
	}
	public void setOwner(User owner) {
		this.owner = owner;
	}

	@Transient
	public long getOwnerId() {
		return this.owner != null ? this.owner.getId() : -1;
	}

	public User getSender() {
		return sender;
	}
	public void setSender(User sender) {
		this.sender = sender;
	}

	@Transient
	public long getSenderId() {
		return this.sender != null ? this.sender.getId() : -1;
	}

	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}

	public boolean isReaded() {
		return readed;
	}
	public void setReaded(boolean readed) {
		this.readed = readed;
	}

	public GregorianCalendar getSendDate() {
		return sendDate;
	}
	public void setSendDate(GregorianCalendar sendDate) {
		this.sendDate = sendDate;
	}
}
